home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
program
/
progem.lzh
/
wind13.prf
< prev
next >
Wrap
Text File
|
1987-06-23
|
19KB
|
363 lines
.!****************************************************************************
.!
.! ANTIC PUBLISHING INC., COPYRIGHT 1985. REPRINTED BY PERMISSION.
.!
.! ** Professional GEM ** by Tim Oren
.!
.! Proff File by ST enthusiasts at
.! Case Western Reserve University
.! Cleveland, Ohio
.! uucp : decvax!cwruecmp!bammi
.! csnet: bammi@case
.! arpa : bammi%case@csnet-relay
.! compuserve: 71515,155
.!
.!****************************************************************************
.!
.!
.!****************************************************************************
.!
.! Begin Part XIII
.!
.!****************************************************************************
.!
.PART XIII A New Form Manager
.PP
This is the 13th installment of ST PRO GEM, and the first
devoted to explaining a large piece of code. This article is also
the second in a series of three concerning GEM user interface
techniques. The code is an alternate form (dialog) manager for
GEM. It is stored as GMCL13.C in DL3 of PCS-58. You should go
and download it now, or you will have no hope of following this
discussion.
.PP
What is unique about this version of the form manager?
First, it implements all of the functions of the standard GEM
form_do routine, as well as adding a "hot spots" feature which
causes selectable objects to become mouse-sensitive, just like
the entries in menu dropdowns. The second (and obvious)
difference is that this form manager is provided in source code
form. This gives you the freedom to examine it and change it to
suit your own needs.
.PP
I have several purposes in presenting this code. It is
intended as an example of GEM program structure, and an
application of some of the techniques presented in earlier
columns. It is also relevant to the continuing thread discussing
the necessity of feedback when constructing a user interface.
.PP
Also, this issue represents the beginning of a fundamental
change in direction for ST PRO GEM. Since this column began last
August, Atari ST developers have increased not only in number, but
in sophistication. A number of books, as well as back issues of
ST PRO GEM, are now available to explain the basics of the ST and
GEM. Quick answers to common questions are available here on
Compuserve's PCS-57 from Atari itself, or from helpful members of
the developer community.
.PP
To reflect these changes, future columns will discuss more
advanced topics in greater depth, with an accent on code which can
be adapted by developers. The program presented in this issue
will be a basis for a number of these discussions. There will be
fewer "encyclopediac" treatments of AES and VDI function calls.
Finally, to give me the time required to create this code or clean
up tools from my "bag of tricks", ST PRO GEM will probably convert
to a monthly format around the start of summer.
.SH ON WITH THE SHOW
Taking your listing in hand, you will
quickly notice two things. First, this program uses the infamous
portability macros, so that it may be used with Intel versions of
GEM. Second, the routines are arranged "bottom up", with the main
at the end, and subroutines going toward the beginning. (This is
a carry-over from my days with ALGOL and PASCAL.) You should now
turn to the form_do entry point near the end of the code.
.PP
One change has been made in the standard calling sequence for
m_do. The starting edit field is now a pointer to a value,
rather than the value itself. The new form_do overwrites the
initial value with the number of the object being edited when the
dialog terminated. Using this information, your program can
restore the situation when the dialog is next called. As before,
if there is NO editable field, the initial value should be zero.
.PP
There are several local variables which maintain vital state
information during the dialog interaction. Edit_obj is the number
of the editable object currently receiving keystrokes. Next_obj
is set when the mouse is clicked over an object. If the object
happens to be editable, next_obj becomes the new edit_obj.
.PP
Three variables are associated with the "hot-spot" feature.
If hot_mode is set to M1_ENTER, then the mouse is outside the area
of the dialog. If it equals M1_EXIT, then the mouse is currently
in the dialog. If it is in the dialog, hot_obj indicates whether
there is an active "hot" object. If its value is NIL (-1), then
there is no active object. Otherwise, it is equal to the number
of the object which is currently "hot", that is, inverted on the
screen. Finally, hot_rect is the current wait rectangle. If the
mouse is outside of the window, then the wait rectangle equals the
dialog's ROOT. If there is a current hot object, then hot_rect
equals that object's screen rectangle. If the mouse is in the
dialog, but not within a hot object, then the wait rectangle
defines the area within which no further collision checks are
necessary. This is arrived at through an algorithm explained
below.
.PP
Form_do's initialization code sets up the hot-spot variables
to trigger if the mouse is within the dialog. It also sets
starting values for edit_obj and next_obj which will cause the
edit startup code to be activated.
.PP
The main portion of form_do is a loop, exhibiting the type of
event driven structure discussed in the last column. Before
entering the evnt_multi wait, the status of next_obj and edit_obj
are checked to see if a new object should be initialized for
editing. If so, objc_edit is called with the EDINIT function
code. NOTE: the objc_edit calling sequence used in this program
differs from the one given in the AES manual, which is incorrect!
You should check the bindings you are using to be sure they will
work with this code, and modify as necessary.
.PP
The evnt_multi is set up to wait for a mouse click (single or
double), for a keyboard input, or for the mouse to make a
"significant" movement, as discussed above. Notice that since
form_do is used as a subroutine, it does not handle messages which
are normally processed by the main loop of your application.
Notice that this creates a mode, and that this routine as written
handles modal dialogs. You could, however, use this code as the
basis for a non-modal dialog handler by drawing the dialog within
a window, and combining the main loop of form_do with the main
loop of your application. (This possibility may be examined in
future columns. In the meantime, it is left as an exercise for
the reader.)
.PP
The event bit vector is returned to the variable "which".
Since events are not mutually exclusive, each possible event type
must be examined in turn before returning to the evnt_multi call.
The form manager's event handling routines are form_hot, for mouse
rectangle event, form_keybd, for character input, and form_button,
for mouse clicks. Form_keybd and form_button are allowed to
terminate the dialog by returning a value of false to the loop
control variable "cont". If termination is imminent, or the user
has clicked on a new editable object, objc_edit is called with
EDEND to remove the cursor from the old object. The normal flow
of control then returns to edit setup and evnt_multi.
.PP
A few cleanup actions are performed upon termination. If the
terminating object (stored in next_obj) is not the same as the
hot_obj, then a race condition has occured and the hot object must
be cleared with objc_toggle before exiting. After this test, the
final edit_obj value is passed back via the parameter, and the
terminating object is returned as the function value.
.SH RELAXEN UND WATCHEN DAS BLINKENLICHTE
Form_hot is
responsible for maintaining on-screen hot-spots, and correctly
updating the internal hot-spot variables. It is about halfway
through the listing.
.PP
he first action in form_hot is to determine if the mouse has
just exited an object which is "hot. In this case, objc_toggle is
called to unhighlight the object and reset